<!-- This comment will put IE 6, 7 and 8 in quirks mode -->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>eCommerce: Plik źródłowy D:/CentrumXP/e-Commerce/eCommerceDev/SklepDAO/PropertyDAO.cs</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javaScript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css"/>
</head>
<body onload='searchBox.OnSelectItem(0);'>
<!-- Wygenerowano przez Doxygen 1.6.1 -->
<script type="text/javascript"><!--
var searchBox = new SearchBox("searchBox", "search",false,'Szukaj');
--></script>
<div class="navigation" id="top">
  <div class="tabs">
    <ul>
      <li><a href="index.html"><span>Strona&nbsp;główna</span></a></li>
      <li><a href="namespaces.html"><span>Pakiety</span></a></li>
      <li><a href="annotated.html"><span>Klasy</span></a></li>
      <li class="current"><a href="files.html"><span>Pliki</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <img id="MSearchSelect" src="search/search.png"
             onmouseover="return searchBox.OnSearchSelectShow()"
             onmouseout="return searchBox.OnSearchSelectHide()"
             alt=""/>
        <input type="text" id="MSearchField" value="Szukaj" accesskey="S"
             onfocus="searchBox.OnSearchFieldFocus(true)" 
             onblur="searchBox.OnSearchFieldFocus(false)" 
             onkeyup="searchBox.OnSearchFieldChange(event)"/>
        <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
        </div>
      </li>
    </ul>
  </div>
  <div class="tabs">
    <ul>
      <li><a href="files.html"><span>Lista&nbsp;plików</span></a></li>
      <li><a href="globals.html"><span>Składowe&nbsp;plików</span></a></li>
    </ul>
  </div>
<h1>D:/CentrumXP/e-Commerce/eCommerceDev/SklepDAO/PropertyDAO.cs</h1><a href="_property_d_a_o_8cs.html">Idź do dokumentacji tego pliku.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a><a class="code" href="_property_d_a_o_8cs.html#a81a223a02c34d82b47199f08308847f2">00001</a> ﻿using <a class="code" href="_common_tools_8cs.html#a81a223a02c34d82b47199f08308847f2">System</a>;
<a name="l00002"></a>00002 <span class="keyword">using</span> <a class="code" href="_common_tools_8cs.html#a81a223a02c34d82b47199f08308847f2">System</a>.Collections.Generic;
<a name="l00003"></a>00003 <span class="keyword">using</span> <a class="code" href="_common_tools_8cs.html#a81a223a02c34d82b47199f08308847f2">System</a>.Data.SqlClient;
<a name="l00004"></a>00004 <span class="keyword">using</span> <a class="code" href="_common_tools_8cs.html#a81a223a02c34d82b47199f08308847f2">System</a>.Data;
<a name="l00005"></a>00005 <span class="keyword">using</span> <a class="code" href="_common_tools_8cs.html#a81a223a02c34d82b47199f08308847f2">System</a>.Text;
<a name="l00006"></a>00006 
<a name="l00007"></a>00007 <span class="keyword">using</span> ShopModel;
<a name="l00008"></a>00008 
<a name="l00009"></a>00009 
<a name="l00010"></a>00010 <span class="keyword">namespace </span>ShopDAO
<a name="l00011"></a>00011 {
<a name="l00012"></a><a class="code" href="class_shop_d_a_o_1_1_property_d_a_o.html">00012</a>     <span class="keyword">public</span> <span class="keyword">class </span><a class="code" href="class_shop_d_a_o_1_1_property_d_a_o.html">PropertyDAO</a>
<a name="l00013"></a>00013     {
<a name="l00014"></a>00014         <span class="keyword">private</span> <span class="keywordtype">string</span> connectionString;
<a name="l00015"></a>00015 
<a name="l00016"></a><a class="code" href="class_shop_d_a_o_1_1_property_d_a_o.html#a8b39360cac58ea97ebb6b780129c6a73">00016</a>         <span class="keyword">public</span> <a class="code" href="class_shop_d_a_o_1_1_property_d_a_o.html#a8b39360cac58ea97ebb6b780129c6a73">PropertyDAO</a>()
<a name="l00017"></a>00017         {
<a name="l00018"></a>00018             connectionString = <a class="code" href="_common_tools_8cs.html#a81a223a02c34d82b47199f08308847f2">System</a>.Configuration.ConfigurationManager.ConnectionStrings[<span class="stringliteral">&quot;csShop&quot;</span>].ConnectionString;
<a name="l00019"></a>00019         }
<a name="l00020"></a>00020 
<a name="l00033"></a><a class="code" href="class_shop_d_a_o_1_1_property_d_a_o.html#af5b031875dfe2d93e81811969a51c055">00033</a>         <span class="keyword">public</span> List&lt;ProductPropertyDetail&gt; <a class="code" href="class_shop_d_a_o_1_1_property_d_a_o.html#af5b031875dfe2d93e81811969a51c055" title="Pobiera wszystkie właściwości w określonym języku, łącznie z możliwymi wartościami...">GetAllProperties</a>(<span class="keywordtype">int</span>? LanguageID)
<a name="l00034"></a>00034         {
<a name="l00035"></a>00035             <a class="code" href="class_shop_model_1_1_product_property_detail.html" title="Klasa opisująca właściwości produktu łącznie z możliwymi wartościami dla...">ProductPropertyDetail</a> property;
<a name="l00036"></a>00036             List&lt;ProductPropertyDetail&gt; result = <span class="keyword">new</span> List&lt;ProductPropertyDetail&gt;();
<a name="l00037"></a>00037             SqlConnection connection = <span class="keyword">new</span> SqlConnection(connectionString);
<a name="l00038"></a>00038             SqlCommand command = connection.CreateCommand();
<a name="l00039"></a>00039             SqlDataReader reader;
<a name="l00040"></a>00040 
<a name="l00041"></a>00041             command.CommandText = <span class="stringliteral">&quot;GetAllProperties&quot;</span>;
<a name="l00042"></a>00042             command.CommandType = CommandType.StoredProcedure;
<a name="l00043"></a>00043 
<a name="l00044"></a>00044             command.Parameters.Add(<span class="keyword">new</span> SqlParameter(<span class="stringliteral">&quot;@LanguageID&quot;</span>, LanguageID));
<a name="l00045"></a>00045 
<a name="l00046"></a>00046             <span class="keywordflow">try</span>
<a name="l00047"></a>00047             {
<a name="l00048"></a>00048                 connection.Open();
<a name="l00049"></a>00049                 reader = command.ExecuteReader(CommandBehavior.CloseConnection);
<a name="l00050"></a>00050 
<a name="l00051"></a>00051                 <span class="keywordflow">while</span> (reader.Read())
<a name="l00052"></a>00052                 {
<a name="l00053"></a>00053                     <span class="keyword">property</span> = <span class="keyword">new</span> <a class="code" href="class_shop_model_1_1_product_property_detail.html" title="Klasa opisująca właściwości produktu łącznie z możliwymi wartościami dla...">ProductPropertyDetail</a>();
<a name="l00054"></a>00054 
<a name="l00055"></a>00055                     <span class="keyword">property</span>.Id = (int)reader[<span class="stringliteral">&quot;IDproperty&quot;</span>];
<a name="l00056"></a>00056                     <span class="keyword">property</span>.TypeOfProperty = (<a class="code" href="namespace_shop_model.html#a98c518c100572eb69c98bd43c7a75a41">PropertyType</a>)reader[<span class="stringliteral">&quot;PropertyType&quot;</span>];
<a name="l00057"></a>00057                     <span class="keyword">property</span>.Name = reader[<span class="stringliteral">&quot;Name&quot;</span>].ToString();
<a name="l00058"></a>00058                     <span class="keyword">property</span>.Description = reader[<span class="stringliteral">&quot;Description&quot;</span>].ToString();
<a name="l00059"></a>00059                     <span class="keyword">property</span>.IsSearchCriterion = (bool)reader[<span class="stringliteral">&quot;IsSearchCriterion&quot;</span>];
<a name="l00060"></a>00060 
<a name="l00061"></a>00061                     <span class="keywordflow">if</span> (property.<a class="code" href="class_shop_model_1_1_product_property.html#afc92bf2ca438dc74ef535b2221e09b1c">TypeOfProperty</a> == <a class="code" href="namespace_shop_model.html#a98c518c100572eb69c98bd43c7a75a41">PropertyType</a>.Dictionary || property.<a class="code" href="class_shop_model_1_1_product_property.html#afc92bf2ca438dc74ef535b2221e09b1c">TypeOfProperty</a> == <a class="code" href="namespace_shop_model.html#a98c518c100572eb69c98bd43c7a75a41">PropertyType</a>.MultiDictionary)
<a name="l00062"></a>00062                     {
<a name="l00063"></a>00063                         <span class="keyword">property</span>.ValuesList = GetDictionaryValue(property.<a class="code" href="class_shop_model_1_1_product_property.html#a59e2088b2d228889cbaeee87c3d59eba" title="Id właściwości.">Id</a>, LanguageID);
<a name="l00064"></a>00064                     }
<a name="l00065"></a>00065 
<a name="l00066"></a>00066                     result.Add(property);
<a name="l00067"></a>00067                 }
<a name="l00068"></a>00068 
<a name="l00069"></a>00069                 <span class="keywordflow">return</span> result;
<a name="l00070"></a>00070             }
<a name="l00071"></a>00071             <span class="keywordflow">catch</span> (Exception ex)
<a name="l00072"></a>00072             {
<a name="l00073"></a>00073                 ErrorLogger.LogError(ex);
<a name="l00074"></a>00074                 <span class="keywordflow">return</span> null;
<a name="l00075"></a>00075             }
<a name="l00076"></a>00076             <span class="keywordflow">finally</span>
<a name="l00077"></a>00077             {
<a name="l00078"></a>00078                 connection.Close();
<a name="l00079"></a>00079             }
<a name="l00080"></a>00080         }
<a name="l00081"></a>00081 
<a name="l00098"></a><a class="code" href="class_shop_d_a_o_1_1_property_d_a_o.html#ad225b9648b83647d3f31d110dfb40caf">00098</a>         <span class="keyword">public</span> <a class="code" href="class_shop_model_1_1_product_property_detail.html" title="Klasa opisująca właściwości produktu łącznie z możliwymi wartościami dla...">ProductPropertyDetail</a> <a class="code" href="class_shop_d_a_o_1_1_property_d_a_o.html#ad225b9648b83647d3f31d110dfb40caf" title="Pobiera informacje o właściwościach wybranego produktu, w określonym języku...">PropertyById</a>(<span class="keywordtype">int</span> PropertyID, <span class="keywordtype">int</span>? LanguageID)
<a name="l00099"></a>00099         {
<a name="l00100"></a>00100             <a class="code" href="class_shop_model_1_1_product_property_detail.html" title="Klasa opisująca właściwości produktu łącznie z możliwymi wartościami dla...">ProductPropertyDetail</a> <span class="keyword">property</span> = null;
<a name="l00101"></a>00101             SqlConnection connection = <span class="keyword">new</span> SqlConnection(connectionString);
<a name="l00102"></a>00102             SqlCommand command = connection.CreateCommand();
<a name="l00103"></a>00103             SqlDataReader reader;
<a name="l00104"></a>00104 
<a name="l00105"></a>00105             command.CommandText = <span class="stringliteral">&quot;PropertyById&quot;</span>;
<a name="l00106"></a>00106             command.CommandType = CommandType.StoredProcedure;
<a name="l00107"></a>00107 
<a name="l00108"></a>00108             command.Parameters.Add(<span class="keyword">new</span> SqlParameter(<span class="stringliteral">&quot;@PropertyID&quot;</span>, PropertyID));
<a name="l00109"></a>00109             command.Parameters.Add(<span class="keyword">new</span> SqlParameter(<span class="stringliteral">&quot;@LanguageID&quot;</span>, LanguageID));
<a name="l00110"></a>00110 
<a name="l00111"></a>00111             <span class="keywordflow">try</span>
<a name="l00112"></a>00112             {
<a name="l00113"></a>00113                 connection.Open();
<a name="l00114"></a>00114                 reader = command.ExecuteReader(CommandBehavior.CloseConnection);
<a name="l00115"></a>00115                 <span class="keywordflow">if</span> (reader.Read())
<a name="l00116"></a>00116                 {
<a name="l00117"></a>00117                     <span class="keyword">property</span> = <span class="keyword">new</span> <a class="code" href="class_shop_model_1_1_product_property_detail.html" title="Klasa opisująca właściwości produktu łącznie z możliwymi wartościami dla...">ProductPropertyDetail</a>();
<a name="l00118"></a>00118                     <span class="keyword">property</span>.Id = (int)reader[<span class="stringliteral">&quot;IDproperty&quot;</span>];
<a name="l00119"></a>00119                     <span class="keyword">property</span>.TypeOfProperty = (<a class="code" href="namespace_shop_model.html#a98c518c100572eb69c98bd43c7a75a41">PropertyType</a>)reader[<span class="stringliteral">&quot;PropertyType&quot;</span>];
<a name="l00120"></a>00120                     <span class="keyword">property</span>.Name = reader[<span class="stringliteral">&quot;Name&quot;</span>].ToString();
<a name="l00121"></a>00121                     <span class="keyword">property</span>.Description = reader[<span class="stringliteral">&quot;Description&quot;</span>].ToString();
<a name="l00122"></a>00122                     <span class="keyword">property</span>.IsSearchCriterion = (bool)reader[<span class="stringliteral">&quot;IsSearchCriterion&quot;</span>];
<a name="l00123"></a>00123 
<a name="l00124"></a>00124                     <span class="keywordflow">if</span> (property.TypeOfProperty == <a class="code" href="namespace_shop_model.html#a98c518c100572eb69c98bd43c7a75a41">PropertyType</a>.Dictionary || property.TypeOfProperty == <a class="code" href="namespace_shop_model.html#a98c518c100572eb69c98bd43c7a75a41">PropertyType</a>.MultiDictionary)
<a name="l00125"></a>00125                     {
<a name="l00126"></a>00126                         <span class="keyword">property</span>.ValuesList = GetDictionaryValue(property.Id, LanguageID);
<a name="l00127"></a>00127                     }
<a name="l00128"></a>00128                 }
<a name="l00129"></a>00129 
<a name="l00130"></a>00130                 reader.Close();
<a name="l00131"></a>00131                 <span class="keywordflow">return</span> property;
<a name="l00132"></a>00132             }
<a name="l00133"></a>00133             <span class="keywordflow">catch</span> (Exception ex)
<a name="l00134"></a>00134             {
<a name="l00135"></a>00135                 ErrorLogger.LogError(ex);
<a name="l00136"></a>00136                 <span class="keywordflow">return</span> null;
<a name="l00137"></a>00137             }
<a name="l00138"></a>00138             <span class="keywordflow">finally</span>
<a name="l00139"></a>00139             {
<a name="l00140"></a>00140                 connection.Close();
<a name="l00141"></a>00141             }
<a name="l00142"></a>00142         }
<a name="l00143"></a>00143 
<a name="l00160"></a>00160         <span class="keyword">private</span> List&lt;DictionaryValue&gt; GetDictionaryValue(<span class="keywordtype">int</span> PropertyID, <span class="keywordtype">int</span>? LanguageID)
<a name="l00161"></a>00161         {
<a name="l00162"></a>00162             List&lt;DictionaryValue&gt; result = <span class="keyword">new</span> List&lt;DictionaryValue&gt;();
<a name="l00163"></a>00163             SqlConnection connection = <span class="keyword">new</span> SqlConnection(connectionString);
<a name="l00164"></a>00164             SqlDataReader reader;
<a name="l00165"></a>00165             <a class="code" href="class_shop_model_1_1_dictionary_value.html" title="Klasa opisująca wartości słownika (Class describing dictionary values).">DictionaryValue</a> tempValue;
<a name="l00166"></a>00166             SqlCommand command = connection.CreateCommand();
<a name="l00167"></a>00167 
<a name="l00168"></a>00168             command.CommandText = <span class="stringliteral">&quot;GetDictionaryValue&quot;</span>;
<a name="l00169"></a>00169             command.CommandType = CommandType.StoredProcedure;
<a name="l00170"></a>00170 
<a name="l00171"></a>00171             command.Parameters.Add(<span class="keyword">new</span> SqlParameter(<span class="stringliteral">&quot;@PropertyID&quot;</span>, PropertyID));
<a name="l00172"></a>00172             command.Parameters.Add(<span class="keyword">new</span> SqlParameter(<span class="stringliteral">&quot;@LanguageID&quot;</span>, LanguageID));
<a name="l00173"></a>00173 
<a name="l00174"></a>00174             <span class="keywordflow">if</span> (connection.State == ConnectionState.Closed)
<a name="l00175"></a>00175             {
<a name="l00176"></a>00176                 connection.Open();
<a name="l00177"></a>00177             }
<a name="l00178"></a>00178 
<a name="l00179"></a>00179             reader = command.ExecuteReader();
<a name="l00180"></a>00180 
<a name="l00181"></a>00181             <span class="keywordflow">while</span> (reader.Read())
<a name="l00182"></a>00182             {
<a name="l00183"></a>00183                 tempValue = <span class="keyword">new</span> <a class="code" href="class_shop_model_1_1_dictionary_value.html" title="Klasa opisująca wartości słownika (Class describing dictionary values).">DictionaryValue</a>();
<a name="l00184"></a>00184                 tempValue.<a class="code" href="class_shop_model_1_1_dictionary_value.html#a2da420791553468f28b119002619c052">Name</a> = (string)reader[<span class="stringliteral">&quot;Value&quot;</span>];
<a name="l00185"></a>00185                 tempValue.<a class="code" href="class_shop_model_1_1_dictionary_value.html#af0387cd94b5a9937575a8ae94a5c5db8">Value</a> = (int)reader[<span class="stringliteral">&quot;IDdescription&quot;</span>];
<a name="l00186"></a>00186                 result.Add(tempValue);
<a name="l00187"></a>00187             }
<a name="l00188"></a>00188 
<a name="l00189"></a>00189             reader.Close();
<a name="l00190"></a>00190 
<a name="l00191"></a>00191             connection.Close();
<a name="l00192"></a>00192 
<a name="l00193"></a>00193             <span class="keywordflow">return</span> result;
<a name="l00194"></a>00194         }
<a name="l00195"></a>00195 
<a name="l00212"></a><a class="code" href="class_shop_d_a_o_1_1_property_d_a_o.html#a2a12841b378e298375e7172536ec964d">00212</a>         <span class="keyword">public</span> List&lt;ProductPropertyDetail&gt; <a class="code" href="class_shop_d_a_o_1_1_property_d_a_o.html#a2a12841b378e298375e7172536ec964d" title="Wybiera wszystkie właściwości dla określonej kategorii w wybranym języku. (Selects...">GetSearchCriteria</a>(<span class="keywordtype">int</span> categoryID, <span class="keywordtype">int</span>? LanguageID)
<a name="l00213"></a>00213         {
<a name="l00214"></a>00214             SqlConnection connection = <span class="keyword">new</span> SqlConnection(connectionString);
<a name="l00215"></a>00215             <a class="code" href="class_shop_model_1_1_product_property_detail.html" title="Klasa opisująca właściwości produktu łącznie z możliwymi wartościami dla...">ProductPropertyDetail</a> tempProperty;
<a name="l00216"></a>00216             List&lt;ProductPropertyDetail&gt; result = <span class="keyword">new</span> List&lt;ProductPropertyDetail&gt;();
<a name="l00217"></a>00217             SqlCommand command = connection.CreateCommand();
<a name="l00218"></a>00218             SqlDataReader reader;
<a name="l00219"></a>00219 
<a name="l00220"></a>00220             command.CommandText = <span class="stringliteral">&quot;GetSearchCriteria&quot;</span>;
<a name="l00221"></a>00221             command.CommandType = CommandType.StoredProcedure;
<a name="l00222"></a>00222             command.Parameters.Add(<span class="keyword">new</span> SqlParameter(<span class="stringliteral">&quot;@category_id&quot;</span>, categoryID));
<a name="l00223"></a>00223             command.Parameters.Add(<span class="keyword">new</span> SqlParameter(<span class="stringliteral">&quot;@LanguageID&quot;</span>, LanguageID));
<a name="l00224"></a>00224 
<a name="l00225"></a>00225             <span class="keywordflow">try</span>
<a name="l00226"></a>00226             {
<a name="l00227"></a>00227                 connection.Open();
<a name="l00228"></a>00228 
<a name="l00229"></a>00229                 reader = command.ExecuteReader(CommandBehavior.CloseConnection);
<a name="l00230"></a>00230 
<a name="l00231"></a>00231                 <span class="keywordflow">while</span> (reader.Read())
<a name="l00232"></a>00232                 {
<a name="l00233"></a>00233                     tempProperty = <span class="keyword">new</span> <a class="code" href="class_shop_model_1_1_product_property_detail.html" title="Klasa opisująca właściwości produktu łącznie z możliwymi wartościami dla...">ProductPropertyDetail</a>();
<a name="l00234"></a>00234                     tempProperty.<a class="code" href="class_shop_model_1_1_product_property.html#a59e2088b2d228889cbaeee87c3d59eba" title="Id właściwości.">Id</a> = (int)reader[<span class="stringliteral">&quot;IDproperty&quot;</span>];
<a name="l00235"></a>00235                     tempProperty.<a class="code" href="class_shop_model_1_1_product_property.html#afc92bf2ca438dc74ef535b2221e09b1c">TypeOfProperty</a> = (<a class="code" href="namespace_shop_model.html#a98c518c100572eb69c98bd43c7a75a41">PropertyType</a>)reader[<span class="stringliteral">&quot;PropertyType&quot;</span>];
<a name="l00236"></a>00236                     tempProperty.<a class="code" href="class_shop_model_1_1_product_property.html#af8d6175437898171abafba0d85724a3a" title="Nazwa właściwości.">Name</a> = (string)reader[<span class="stringliteral">&quot;Name&quot;</span>];
<a name="l00237"></a>00237                     tempProperty.<a class="code" href="class_shop_model_1_1_product_property.html#a7225e2737eec785666b972716ef46026">IsSearchCriterion</a> = (bool)reader[<span class="stringliteral">&quot;IsSearchCriterion&quot;</span>];
<a name="l00238"></a>00238 
<a name="l00239"></a>00239                     <span class="keywordflow">if</span> (tempProperty.<a class="code" href="class_shop_model_1_1_product_property.html#afc92bf2ca438dc74ef535b2221e09b1c">TypeOfProperty</a> == <a class="code" href="namespace_shop_model.html#a98c518c100572eb69c98bd43c7a75a41">PropertyType</a>.Dictionary || tempProperty.<a class="code" href="class_shop_model_1_1_product_property.html#afc92bf2ca438dc74ef535b2221e09b1c">TypeOfProperty</a> == <a class="code" href="namespace_shop_model.html#a98c518c100572eb69c98bd43c7a75a41">PropertyType</a>.MultiDictionary)
<a name="l00240"></a>00240                     {
<a name="l00241"></a>00241                         tempProperty.<a class="code" href="class_shop_model_1_1_product_property_detail.html#a280e804f3106f9e2cc526d3cd89334c6" title="Lista możliwych wartości dla danej właściwości.">ValuesList</a> = GetDictionaryValue(tempProperty.<a class="code" href="class_shop_model_1_1_product_property.html#a59e2088b2d228889cbaeee87c3d59eba" title="Id właściwości.">Id</a>, LanguageID);
<a name="l00242"></a>00242                     }
<a name="l00243"></a>00243                     result.Add(tempProperty);
<a name="l00244"></a>00244                 }
<a name="l00245"></a>00245 
<a name="l00246"></a>00246                 reader.Close();
<a name="l00247"></a>00247 
<a name="l00248"></a>00248                 <span class="keywordflow">return</span> result;
<a name="l00249"></a>00249             }
<a name="l00250"></a>00250             <span class="keywordflow">catch</span> (Exception ex)
<a name="l00251"></a>00251             {
<a name="l00252"></a>00252                 ErrorLogger.LogError(ex);
<a name="l00253"></a>00253                 <span class="keywordflow">return</span> null;
<a name="l00254"></a>00254             }
<a name="l00255"></a>00255             <span class="keywordflow">finally</span>
<a name="l00256"></a>00256             {
<a name="l00257"></a>00257                 connection.Close();
<a name="l00258"></a>00258             }
<a name="l00259"></a>00259         }
<a name="l00260"></a>00260 
<a name="l00277"></a><a class="code" href="class_shop_d_a_o_1_1_property_d_a_o.html#a9f880c4724794c33048e7057283b27b6">00277</a>         <span class="keyword">public</span> List&lt;ProductPropertyDetail&gt; <a class="code" href="class_shop_d_a_o_1_1_property_d_a_o.html#a9f880c4724794c33048e7057283b27b6" title="Pobiera właściwości dala danej kategorii w określonym języku. (Downloads properties...">PropertyByCategory</a>(<span class="keywordtype">int</span> categoryID, <span class="keywordtype">int</span>? LanguageID)
<a name="l00278"></a>00278         {
<a name="l00279"></a>00279             SqlConnection connection = <span class="keyword">new</span> SqlConnection(connectionString);
<a name="l00280"></a>00280             <a class="code" href="class_shop_model_1_1_product_property_detail.html" title="Klasa opisująca właściwości produktu łącznie z możliwymi wartościami dla...">ProductPropertyDetail</a> tempProperty;
<a name="l00281"></a>00281             List&lt;ProductPropertyDetail&gt; result = <span class="keyword">new</span> List&lt;ProductPropertyDetail&gt;();
<a name="l00282"></a>00282             SqlCommand command = connection.CreateCommand();
<a name="l00283"></a>00283             SqlDataReader reader;
<a name="l00284"></a>00284 
<a name="l00285"></a>00285             command.CommandText = <span class="stringliteral">&quot;PropertyByCategory&quot;</span>;
<a name="l00286"></a>00286             command.CommandType = CommandType.StoredProcedure;
<a name="l00287"></a>00287 
<a name="l00288"></a>00288             command.Parameters.Add(<span class="keyword">new</span> SqlParameter(<span class="stringliteral">&quot;@category_id&quot;</span>, categoryID));
<a name="l00289"></a>00289             command.Parameters.Add(<span class="keyword">new</span> SqlParameter(<span class="stringliteral">&quot;@LanguageID&quot;</span>, LanguageID));
<a name="l00290"></a>00290 
<a name="l00291"></a>00291             <span class="keywordflow">try</span>
<a name="l00292"></a>00292             {
<a name="l00293"></a>00293                 connection.Open();
<a name="l00294"></a>00294 
<a name="l00295"></a>00295                 reader = command.ExecuteReader(CommandBehavior.CloseConnection);
<a name="l00296"></a>00296 
<a name="l00297"></a>00297                 <span class="keywordflow">while</span> (reader.Read())
<a name="l00298"></a>00298                 {
<a name="l00299"></a>00299                     tempProperty = <span class="keyword">new</span> <a class="code" href="class_shop_model_1_1_product_property_detail.html" title="Klasa opisująca właściwości produktu łącznie z możliwymi wartościami dla...">ProductPropertyDetail</a>();
<a name="l00300"></a>00300                     tempProperty.<a class="code" href="class_shop_model_1_1_product_property.html#a59e2088b2d228889cbaeee87c3d59eba" title="Id właściwości.">Id</a> = (int)reader[<span class="stringliteral">&quot;IDproperty&quot;</span>];
<a name="l00301"></a>00301                     tempProperty.<a class="code" href="class_shop_model_1_1_product_property.html#afc92bf2ca438dc74ef535b2221e09b1c">TypeOfProperty</a> = (<a class="code" href="namespace_shop_model.html#a98c518c100572eb69c98bd43c7a75a41">PropertyType</a>)reader[<span class="stringliteral">&quot;PropertyType&quot;</span>];
<a name="l00302"></a>00302                     tempProperty.<a class="code" href="class_shop_model_1_1_product_property.html#af8d6175437898171abafba0d85724a3a" title="Nazwa właściwości.">Name</a> = (string)reader[<span class="stringliteral">&quot;Name&quot;</span>];
<a name="l00303"></a>00303                     tempProperty.<a class="code" href="class_shop_model_1_1_product_property.html#a7225e2737eec785666b972716ef46026">IsSearchCriterion</a> = (bool)reader[<span class="stringliteral">&quot;IsSearchCriterion&quot;</span>];
<a name="l00304"></a>00304 
<a name="l00305"></a>00305                     <span class="keywordflow">if</span> (tempProperty.<a class="code" href="class_shop_model_1_1_product_property.html#afc92bf2ca438dc74ef535b2221e09b1c">TypeOfProperty</a> == <a class="code" href="namespace_shop_model.html#a98c518c100572eb69c98bd43c7a75a41">PropertyType</a>.Dictionary || tempProperty.<a class="code" href="class_shop_model_1_1_product_property.html#afc92bf2ca438dc74ef535b2221e09b1c">TypeOfProperty</a> == <a class="code" href="namespace_shop_model.html#a98c518c100572eb69c98bd43c7a75a41">PropertyType</a>.MultiDictionary)
<a name="l00306"></a>00306                     {
<a name="l00307"></a>00307                         tempProperty.<a class="code" href="class_shop_model_1_1_product_property_detail.html#a280e804f3106f9e2cc526d3cd89334c6" title="Lista możliwych wartości dla danej właściwości.">ValuesList</a> = GetDictionaryValue(tempProperty.<a class="code" href="class_shop_model_1_1_product_property.html#a59e2088b2d228889cbaeee87c3d59eba" title="Id właściwości.">Id</a>, LanguageID);
<a name="l00308"></a>00308                     }
<a name="l00309"></a>00309                     result.Add(tempProperty);
<a name="l00310"></a>00310                 }
<a name="l00311"></a>00311 
<a name="l00312"></a>00312                 reader.Close();
<a name="l00313"></a>00313 
<a name="l00314"></a>00314                 <span class="keywordflow">return</span> result;
<a name="l00315"></a>00315             }
<a name="l00316"></a>00316             <span class="keywordflow">catch</span> (Exception ex)
<a name="l00317"></a>00317             {
<a name="l00318"></a>00318                 ErrorLogger.LogError(ex);
<a name="l00319"></a>00319                 <span class="keywordflow">return</span> null;
<a name="l00320"></a>00320             }
<a name="l00321"></a>00321             <span class="keywordflow">finally</span>
<a name="l00322"></a>00322             {
<a name="l00323"></a>00323                 connection.Close();
<a name="l00324"></a>00324             }
<a name="l00325"></a>00325         }
<a name="l00326"></a>00326 
<a name="l00343"></a><a class="code" href="class_shop_d_a_o_1_1_property_d_a_o.html#a26f593a8b61e1ceb175ca346e06fd1c8">00343</a>         <span class="keyword">public</span> <span class="keywordtype">bool</span> <a class="code" href="class_shop_d_a_o_1_1_property_d_a_o.html#a26f593a8b61e1ceb175ca346e06fd1c8" title="Usuwa wartości z dziennika. (Deletes values from the dictionary.).">RemoveDictionaryValues</a>(List&lt;int&gt; ValuesToRemove, out List&lt;int&gt; cantRemove)
<a name="l00344"></a>00344         {
<a name="l00345"></a>00345             cantRemove = <span class="keyword">new</span> List&lt;int&gt;();
<a name="l00346"></a>00346 
<a name="l00347"></a>00347             <span class="keywordflow">if</span> (ValuesToRemove != null &amp;&amp; ValuesToRemove.Count &gt; 0)
<a name="l00348"></a>00348             {
<a name="l00349"></a>00349                 SqlConnection sqlC = <span class="keyword">new</span> SqlConnection(connectionString);
<a name="l00350"></a>00350                 SqlCommand command = sqlC.CreateCommand();
<a name="l00351"></a>00351                 SqlTransaction transaction = null;
<a name="l00352"></a>00352 
<a name="l00353"></a>00353                 command.CommandText = <span class="stringliteral">&quot;RemoveDictionaryValue&quot;</span>;
<a name="l00354"></a>00354                 command.CommandType = CommandType.StoredProcedure;
<a name="l00355"></a>00355 
<a name="l00356"></a>00356                 command.Parameters.Add(<span class="keyword">new</span> SqlParameter(<span class="stringliteral">&quot;@dictionary_id&quot;</span>, SqlDbType.Int));
<a name="l00357"></a>00357 
<a name="l00358"></a>00358                 <span class="keywordflow">try</span>
<a name="l00359"></a>00359                 {
<a name="l00360"></a>00360                     sqlC.Open();
<a name="l00361"></a>00361                     transaction = sqlC.BeginTransaction();
<a name="l00362"></a>00362                     command.Transaction = transaction;
<a name="l00363"></a>00363 
<a name="l00364"></a>00364                     <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; ValuesToRemove.Count; i++)
<a name="l00365"></a>00365                     {
<a name="l00366"></a>00366                         command.Parameters[<span class="stringliteral">&quot;@dictionary_id&quot;</span>].Value = ValuesToRemove[i];
<a name="l00367"></a>00367 
<a name="l00368"></a>00368                         <span class="keywordflow">if</span> (!Convert.ToBoolean(command.ExecuteScalar()))
<a name="l00369"></a>00369                             cantRemove.Add(ValuesToRemove[i]);
<a name="l00370"></a>00370                     }
<a name="l00371"></a>00371 
<a name="l00372"></a>00372                     transaction.Commit();
<a name="l00373"></a>00373                     <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00374"></a>00374                 }
<a name="l00375"></a>00375                 <span class="keywordflow">catch</span> (Exception ex)
<a name="l00376"></a>00376                 {
<a name="l00377"></a>00377                     ErrorLogger.LogError(ex);
<a name="l00378"></a>00378 
<a name="l00379"></a>00379                     <span class="keywordflow">if</span> (sqlC.State == ConnectionState.Open &amp;&amp; transaction != null)
<a name="l00380"></a>00380                         transaction.Rollback();
<a name="l00381"></a>00381 
<a name="l00382"></a>00382                     <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00383"></a>00383                 }
<a name="l00384"></a>00384                 <span class="keywordflow">finally</span>
<a name="l00385"></a>00385                 {
<a name="l00386"></a>00386                     sqlC.Close();
<a name="l00387"></a>00387                 }
<a name="l00388"></a>00388             }
<a name="l00389"></a>00389 
<a name="l00390"></a>00390             <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00391"></a>00391         }
<a name="l00392"></a>00392 
<a name="l00409"></a><a class="code" href="class_shop_d_a_o_1_1_property_d_a_o.html#a3079dcfd36db57e61f23cb018b5df89d">00409</a>         <span class="keyword">public</span> <span class="keywordtype">bool</span> <a class="code" href="class_shop_d_a_o_1_1_property_d_a_o.html#a3079dcfd36db57e61f23cb018b5df89d" title="Uaktualnia warosci dziennika. (Updates dictionary values.).">UpdateDictionaryValue</a>(List&lt;DictionaryValue&gt; newValueList, <span class="keywordtype">int</span>? LanguageID)
<a name="l00410"></a>00410         {
<a name="l00411"></a>00411             SqlConnection connection = <span class="keyword">new</span> SqlConnection(connectionString);
<a name="l00412"></a>00412             SqlCommand sqlCommand = connection.CreateCommand();
<a name="l00413"></a>00413 
<a name="l00414"></a>00414             sqlCommand.CommandText = <span class="stringliteral">&quot;SaveDictionaryValue&quot;</span>;
<a name="l00415"></a>00415             sqlCommand.CommandType = CommandType.StoredProcedure;
<a name="l00416"></a>00416 
<a name="l00417"></a>00417             sqlCommand.Parameters.Add(<span class="keyword">new</span> SqlParameter(<span class="stringliteral">&quot;@DictionaryID&quot;</span>, null));
<a name="l00418"></a>00418             sqlCommand.Parameters.Add(<span class="keyword">new</span> SqlParameter(<span class="stringliteral">&quot;@Value&quot;</span>, null));
<a name="l00419"></a>00419             sqlCommand.Parameters.Add(<span class="keyword">new</span> SqlParameter(<span class="stringliteral">&quot;@LanguageID&quot;</span>, LanguageID));
<a name="l00420"></a>00420 
<a name="l00421"></a>00421             <span class="keywordflow">try</span>
<a name="l00422"></a>00422             {
<a name="l00423"></a>00423                 connection.Open();
<a name="l00424"></a>00424 
<a name="l00425"></a>00425                 <span class="keywordflow">foreach</span> (<a class="code" href="class_shop_model_1_1_dictionary_value.html" title="Klasa opisująca wartości słownika (Class describing dictionary values).">DictionaryValue</a> current <span class="keywordflow">in</span> newValueList)
<a name="l00426"></a>00426                 {
<a name="l00427"></a>00427                     sqlCommand.Parameters[<span class="stringliteral">&quot;@DictionaryID&quot;</span>].Value = current.<a class="code" href="class_shop_model_1_1_dictionary_value.html#af0387cd94b5a9937575a8ae94a5c5db8">Value</a>;
<a name="l00428"></a>00428                     sqlCommand.Parameters[<span class="stringliteral">&quot;@Value&quot;</span>].Value = current.<a class="code" href="class_shop_model_1_1_dictionary_value.html#a2da420791553468f28b119002619c052">Name</a>;
<a name="l00429"></a>00429 
<a name="l00430"></a>00430                     sqlCommand.ExecuteNonQuery();
<a name="l00431"></a>00431                 }
<a name="l00432"></a>00432                 <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00433"></a>00433             }
<a name="l00434"></a>00434             <span class="keywordflow">catch</span> (Exception ex)
<a name="l00435"></a>00435             {
<a name="l00436"></a>00436                 ErrorLogger.LogError(ex);
<a name="l00437"></a>00437                 <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00438"></a>00438             }
<a name="l00439"></a>00439             <span class="keywordflow">finally</span>
<a name="l00440"></a>00440             {
<a name="l00441"></a>00441                 connection.Close();
<a name="l00442"></a>00442             }
<a name="l00443"></a>00443         }
<a name="l00444"></a>00444 
<a name="l00465"></a><a class="code" href="class_shop_d_a_o_1_1_property_d_a_o.html#a1caa360e803cd2af3f8a9f74bd40f242">00465</a>         <span class="keyword">public</span> <span class="keywordtype">bool</span> <a class="code" href="class_shop_d_a_o_1_1_property_d_a_o.html#a1caa360e803cd2af3f8a9f74bd40f242" title="Dodaje wartości do słownika. (Adds values to the dictionary.).">AddDictionaryValue</a>(List&lt;string&gt; values, <span class="keywordtype">int</span> propertyId, <span class="keywordtype">int</span>? LanguageID)
<a name="l00466"></a>00466         {
<a name="l00467"></a>00467             <span class="keywordtype">int</span> index = 0;
<a name="l00468"></a>00468             SqlConnection connection = <span class="keyword">new</span> SqlConnection(connectionString);
<a name="l00469"></a>00469             SqlCommand sqlCommand = connection.CreateCommand();
<a name="l00470"></a>00470 
<a name="l00471"></a>00471             StringBuilder command = <span class="keyword">new</span> StringBuilder();
<a name="l00472"></a>00472             <span class="keywordflow">foreach</span> (<span class="keywordtype">string</span> current <span class="keywordflow">in</span> values)
<a name="l00473"></a>00473             {
<a name="l00474"></a>00474                 command.Append(<span class="stringliteral">&quot;EXEC SaveDictionaryValue NULL, &quot;</span>);
<a name="l00475"></a>00475                 command.Append(propertyId);
<a name="l00476"></a>00476                 command.Append(<span class="stringliteral">&quot;,@param&quot;</span>);
<a name="l00477"></a>00477                 command.Append(index);
<a name="l00478"></a>00478                 command.Append(<span class="stringliteral">&quot;,&quot;</span>);
<a name="l00479"></a>00479                 command.Append(LanguageID);
<a name="l00480"></a>00480                 command.Append(<span class="stringliteral">&quot;;&quot;</span>);
<a name="l00481"></a>00481 
<a name="l00482"></a>00482                 sqlCommand.Parameters.Add(<span class="keyword">new</span> SqlParameter(<span class="stringliteral">&quot;@param&quot;</span> + index.ToString(), current));
<a name="l00483"></a>00483                 index++;
<a name="l00484"></a>00484             }
<a name="l00485"></a>00485 
<a name="l00486"></a>00486             sqlCommand.CommandText = command.ToString();
<a name="l00487"></a>00487 
<a name="l00488"></a>00488 
<a name="l00489"></a>00489             <span class="keywordflow">try</span>
<a name="l00490"></a>00490             {
<a name="l00491"></a>00491                 connection.Open();
<a name="l00492"></a>00492                 sqlCommand.ExecuteNonQuery();
<a name="l00493"></a>00493 
<a name="l00494"></a>00494                 <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00495"></a>00495             }
<a name="l00496"></a>00496             <span class="keywordflow">catch</span> (Exception ex)
<a name="l00497"></a>00497             {
<a name="l00498"></a>00498                 ErrorLogger.LogError(ex);
<a name="l00499"></a>00499                 <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00500"></a>00500             }
<a name="l00501"></a>00501             <span class="keywordflow">finally</span>
<a name="l00502"></a>00502             {
<a name="l00503"></a>00503                 connection.Close();
<a name="l00504"></a>00504             }
<a name="l00505"></a>00505         }
<a name="l00506"></a>00506 
<a name="l00523"></a><a class="code" href="class_shop_d_a_o_1_1_property_d_a_o.html#a70ca04eb72664a9e1f287cf34842e048">00523</a>         <span class="keyword">public</span> <span class="keywordtype">bool</span> <a class="code" href="class_shop_d_a_o_1_1_property_d_a_o.html#a70ca04eb72664a9e1f287cf34842e048" title="Zmienia informacje o wybranej właściwość w określonym języku. (Changes information...">UpdateProperty</a>(<a class="code" href="class_shop_model_1_1_product_property_detail.html" title="Klasa opisująca właściwości produktu łącznie z możliwymi wartościami dla...">ProductPropertyDetail</a> item, <span class="keywordtype">int</span>? LanguageID)
<a name="l00524"></a>00524         {
<a name="l00525"></a>00525             SqlConnection connection = <span class="keyword">new</span> SqlConnection(connectionString);
<a name="l00526"></a>00526             SqlCommand sqlCommand = connection.CreateCommand();
<a name="l00527"></a>00527 
<a name="l00528"></a>00528             sqlCommand.CommandText = <span class="stringliteral">&quot;SaveProperty&quot;</span>;
<a name="l00529"></a>00529             sqlCommand.CommandType = CommandType.StoredProcedure;
<a name="l00530"></a>00530             sqlCommand.Parameters.Add(<span class="keyword">new</span> SqlParameter(<span class="stringliteral">&quot;@PropertyID&quot;</span>, item.<a class="code" href="class_shop_model_1_1_product_property.html#a59e2088b2d228889cbaeee87c3d59eba" title="Id właściwości.">Id</a>));
<a name="l00531"></a>00531             sqlCommand.Parameters.Add(<span class="keyword">new</span> SqlParameter(<span class="stringliteral">&quot;@Name&quot;</span>, item.<a class="code" href="class_shop_model_1_1_product_property.html#af8d6175437898171abafba0d85724a3a" title="Nazwa właściwości.">Name</a>));
<a name="l00532"></a>00532             sqlCommand.Parameters.Add(<span class="keyword">new</span> SqlParameter(<span class="stringliteral">&quot;@Description&quot;</span>, item.<a class="code" href="class_shop_model_1_1_product_property.html#a61f8d7224de93f31b2549079e6089162">Description</a>));
<a name="l00533"></a>00533             sqlCommand.Parameters.Add(<span class="keyword">new</span> SqlParameter(<span class="stringliteral">&quot;@LanguageID&quot;</span>, LanguageID));
<a name="l00534"></a>00534             sqlCommand.Parameters.Add(<span class="keyword">new</span> SqlParameter(<span class="stringliteral">&quot;@PropertyType&quot;</span>, (<span class="keywordtype">int</span>)item.<a class="code" href="class_shop_model_1_1_product_property.html#afc92bf2ca438dc74ef535b2221e09b1c">TypeOfProperty</a>));
<a name="l00535"></a>00535             sqlCommand.Parameters.Add(<span class="keyword">new</span> SqlParameter(<span class="stringliteral">&quot;@IsSearchCriterion&quot;</span>, item.<a class="code" href="class_shop_model_1_1_product_property.html#a7225e2737eec785666b972716ef46026">IsSearchCriterion</a>));
<a name="l00536"></a>00536 
<a name="l00537"></a>00537             <span class="keywordflow">try</span>
<a name="l00538"></a>00538             {
<a name="l00539"></a>00539                 connection.Open();
<a name="l00540"></a>00540                 sqlCommand.ExecuteNonQuery();
<a name="l00541"></a>00541 
<a name="l00542"></a>00542                 <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00543"></a>00543             }
<a name="l00544"></a>00544             <span class="keywordflow">catch</span> (Exception ex)
<a name="l00545"></a>00545             {
<a name="l00546"></a>00546                 ErrorLogger.LogError(ex);
<a name="l00547"></a>00547                 <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00548"></a>00548             }
<a name="l00549"></a>00549             <span class="keywordflow">finally</span>
<a name="l00550"></a>00550             {
<a name="l00551"></a>00551                 connection.Close();
<a name="l00552"></a>00552             }
<a name="l00553"></a>00553 
<a name="l00554"></a>00554         }
<a name="l00555"></a>00555 
<a name="l00568"></a><a class="code" href="class_shop_d_a_o_1_1_property_d_a_o.html#a06db955e99c6ab4f1de2e2f1d0c24d79">00568</a>         <span class="keyword">public</span> List&lt;int&gt; <a class="code" href="class_shop_d_a_o_1_1_property_d_a_o.html#a06db955e99c6ab4f1de2e2f1d0c24d79" title="Pobiera unikalne ID kategorii zawierających wybraną właściwość. (Downloads...">CategoryBelongProperty</a>(<span class="keywordtype">int</span> propertyId)
<a name="l00569"></a>00569         {
<a name="l00570"></a>00570             List&lt;int&gt; result = <span class="keyword">new</span> List&lt;int&gt;();
<a name="l00571"></a>00571             SqlConnection connection = <span class="keyword">new</span> SqlConnection(connectionString);
<a name="l00572"></a>00572             SqlCommand sqlCommand = connection.CreateCommand();
<a name="l00573"></a>00573             SqlDataReader reader;
<a name="l00574"></a>00574 
<a name="l00575"></a>00575             sqlCommand.CommandText = <span class="stringliteral">&quot;GetPropertyCategoryID&quot;</span>;
<a name="l00576"></a>00576             sqlCommand.CommandType = CommandType.StoredProcedure;
<a name="l00577"></a>00577 
<a name="l00578"></a>00578             sqlCommand.Parameters.Add(<span class="keyword">new</span> SqlParameter(<span class="stringliteral">&quot;@property_id&quot;</span>, propertyId));
<a name="l00579"></a>00579 
<a name="l00580"></a>00580             <span class="keywordflow">try</span>
<a name="l00581"></a>00581             {
<a name="l00582"></a>00582                 connection.Open();
<a name="l00583"></a>00583                 reader = sqlCommand.ExecuteReader(CommandBehavior.CloseConnection);
<a name="l00584"></a>00584 
<a name="l00585"></a>00585                 <span class="keywordflow">while</span> (reader.Read())
<a name="l00586"></a>00586                 {
<a name="l00587"></a>00587                     result.Add((<span class="keywordtype">int</span>)reader[0]);
<a name="l00588"></a>00588                 }
<a name="l00589"></a>00589 
<a name="l00590"></a>00590                 reader.Close();
<a name="l00591"></a>00591                 <span class="keywordflow">return</span> result;
<a name="l00592"></a>00592             }
<a name="l00593"></a>00593             <span class="keywordflow">catch</span> (Exception ex)
<a name="l00594"></a>00594             {
<a name="l00595"></a>00595                 ErrorLogger.LogError(ex);
<a name="l00596"></a>00596                 <span class="keywordflow">return</span> null;
<a name="l00597"></a>00597             }
<a name="l00598"></a>00598             <span class="keywordflow">finally</span>
<a name="l00599"></a>00599             {
<a name="l00600"></a>00600                 connection.Close();
<a name="l00601"></a>00601             }
<a name="l00602"></a>00602         }
<a name="l00603"></a>00603 
<a name="l00620"></a><a class="code" href="class_shop_d_a_o_1_1_property_d_a_o.html#a1b9d8cf8274ac405d872861515d26511">00620</a>         <span class="keyword">public</span> <span class="keywordtype">bool</span> <a class="code" href="class_shop_d_a_o_1_1_property_d_a_o.html#a1b9d8cf8274ac405d872861515d26511" title="Dodaje wybraną właściwość zd wskazanych kategorii. (Adds chosen property from...">AddPropertyToCategories</a>(<span class="keywordtype">int</span> propertyId, List&lt;int&gt; categoriesList)
<a name="l00621"></a>00621         {
<a name="l00622"></a>00622             <span class="keywordflow">if</span> (categoriesList.Count == 0)
<a name="l00623"></a>00623                 <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00624"></a>00624 
<a name="l00625"></a>00625             SqlConnection connection = <span class="keyword">new</span> SqlConnection(connectionString);
<a name="l00626"></a>00626             SqlCommand sqlCommand = connection.CreateCommand();
<a name="l00627"></a>00627 
<a name="l00628"></a>00628             sqlCommand.CommandText = <span class="stringliteral">&quot;AddPropertyToCategories&quot;</span>;
<a name="l00629"></a>00629             sqlCommand.CommandType = CommandType.StoredProcedure;
<a name="l00630"></a>00630 
<a name="l00631"></a>00631             sqlCommand.Parameters.Add(<span class="keyword">new</span> SqlParameter(<span class="stringliteral">&quot;@CategoryID&quot;</span>, null));
<a name="l00632"></a>00632             sqlCommand.Parameters.Add(<span class="keyword">new</span> SqlParameter(<span class="stringliteral">&quot;@PropertyId&quot;</span>, propertyId));
<a name="l00633"></a>00633 
<a name="l00634"></a>00634             <span class="keywordflow">try</span>
<a name="l00635"></a>00635             {
<a name="l00636"></a>00636                 connection.Open();
<a name="l00637"></a>00637 
<a name="l00638"></a>00638                 <span class="keywordflow">foreach</span> (<span class="keywordtype">int</span> current <span class="keywordflow">in</span> categoriesList)
<a name="l00639"></a>00639                 {
<a name="l00640"></a>00640                     sqlCommand.Parameters[<span class="stringliteral">&quot;@CategoryID&quot;</span>].Value = current;
<a name="l00641"></a>00641 
<a name="l00642"></a>00642                     sqlCommand.ExecuteNonQuery();
<a name="l00643"></a>00643                 }
<a name="l00644"></a>00644 
<a name="l00645"></a>00645                 <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00646"></a>00646             }
<a name="l00647"></a>00647             <span class="keywordflow">catch</span> (Exception ex)
<a name="l00648"></a>00648             {
<a name="l00649"></a>00649                 ErrorLogger.LogError(ex);
<a name="l00650"></a>00650                 <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00651"></a>00651             }
<a name="l00652"></a>00652             <span class="keywordflow">finally</span>
<a name="l00653"></a>00653             {
<a name="l00654"></a>00654                 connection.Close();
<a name="l00655"></a>00655             }
<a name="l00656"></a>00656         }
<a name="l00657"></a>00657 
<a name="l00674"></a><a class="code" href="class_shop_d_a_o_1_1_property_d_a_o.html#afbe7e5c5107619336f7f8a96c6b9b05a">00674</a>         <span class="keyword">public</span> <span class="keywordtype">bool</span> <a class="code" href="class_shop_d_a_o_1_1_property_d_a_o.html#afbe7e5c5107619336f7f8a96c6b9b05a" title="Usuwa wybraną właściwość ze wskazanych kategorii. (Returns chosen property from...">RemovePropertyFromCategories</a>(<span class="keywordtype">int</span> propertyId, List&lt;int&gt; categoriesList)
<a name="l00675"></a>00675         {
<a name="l00676"></a>00676             SqlConnection connection = <span class="keyword">new</span> SqlConnection(connectionString);
<a name="l00677"></a>00677             SqlCommand sqlCommand = connection.CreateCommand();
<a name="l00678"></a>00678 
<a name="l00679"></a>00679             sqlCommand.CommandText = <span class="stringliteral">&quot;RemovePropertyFromCategories&quot;</span>;
<a name="l00680"></a>00680             sqlCommand.CommandType = CommandType.StoredProcedure;
<a name="l00681"></a>00681 
<a name="l00682"></a>00682             <span class="keywordtype">string</span> categories = <span class="stringliteral">&quot;&quot;</span>;
<a name="l00683"></a>00683 
<a name="l00684"></a>00684             <span class="keywordflow">foreach</span> (<span class="keywordtype">int</span> current <span class="keywordflow">in</span> categoriesList)
<a name="l00685"></a>00685             {
<a name="l00686"></a>00686                 categories += current;
<a name="l00687"></a>00687                 categories += <span class="stringliteral">&quot;,&quot;</span>;
<a name="l00688"></a>00688             }
<a name="l00689"></a>00689             categories = categories.Remove(categories.Length - 1, 1);
<a name="l00690"></a>00690 
<a name="l00691"></a>00691             sqlCommand.Parameters.Add(<span class="keyword">new</span> SqlParameter(<span class="stringliteral">&quot;@categoriesList&quot;</span>, categories));
<a name="l00692"></a>00692             sqlCommand.Parameters.Add(<span class="keyword">new</span> SqlParameter(<span class="stringliteral">&quot;@propertyId&quot;</span>, propertyId));
<a name="l00693"></a>00693 
<a name="l00694"></a>00694             <span class="keywordflow">try</span>
<a name="l00695"></a>00695             {
<a name="l00696"></a>00696                 connection.Open();
<a name="l00697"></a>00697 
<a name="l00698"></a>00698                 sqlCommand.ExecuteNonQuery();
<a name="l00699"></a>00699                 <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00700"></a>00700             }
<a name="l00701"></a>00701             <span class="keywordflow">catch</span> (Exception ex)
<a name="l00702"></a>00702             {
<a name="l00703"></a>00703                 ErrorLogger.LogError(ex);
<a name="l00704"></a>00704                 <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00705"></a>00705             }
<a name="l00706"></a>00706             <span class="keywordflow">finally</span>
<a name="l00707"></a>00707             {
<a name="l00708"></a>00708                 connection.Close();
<a name="l00709"></a>00709             }
<a name="l00710"></a>00710         }
<a name="l00711"></a>00711 
<a name="l00728"></a><a class="code" href="class_shop_d_a_o_1_1_property_d_a_o.html#aead4765132e1a5b59aec8522b1e9bcd8">00728</a>         <span class="keyword">public</span> <span class="keywordtype">int</span> <a class="code" href="class_shop_d_a_o_1_1_property_d_a_o.html#aead4765132e1a5b59aec8522b1e9bcd8" title="Dodaje właściwość do bazy. (Adds property to the database.).">AddProperty</a>(<a class="code" href="class_shop_model_1_1_product_property_detail.html" title="Klasa opisująca właściwości produktu łącznie z możliwymi wartościami dla...">ProductPropertyDetail</a> property, <span class="keywordtype">int</span>? LanguageID)
<a name="l00729"></a>00729         {
<a name="l00730"></a>00730             <span class="keywordtype">int</span> <span class="keywordtype">id</span> = 0;
<a name="l00731"></a>00731             SqlConnection connection = <span class="keyword">new</span> SqlConnection(connectionString);
<a name="l00732"></a>00732             SqlCommand sqlCommand = connection.CreateCommand();
<a name="l00733"></a>00733 
<a name="l00734"></a>00734             sqlCommand.CommandText = <span class="stringliteral">&quot;SaveProperty&quot;</span>;
<a name="l00735"></a>00735             sqlCommand.CommandType = CommandType.StoredProcedure;
<a name="l00736"></a>00736             sqlCommand.Parameters.Add(<span class="keyword">new</span> SqlParameter(<span class="stringliteral">&quot;@Name&quot;</span>, property.<a class="code" href="class_shop_model_1_1_product_property.html#af8d6175437898171abafba0d85724a3a" title="Nazwa właściwości.">Name</a>));
<a name="l00737"></a>00737             sqlCommand.Parameters.Add(<span class="keyword">new</span> SqlParameter(<span class="stringliteral">&quot;@Description&quot;</span>, property.<a class="code" href="class_shop_model_1_1_product_property.html#a61f8d7224de93f31b2549079e6089162">Description</a>));
<a name="l00738"></a>00738             sqlCommand.Parameters.Add(<span class="keyword">new</span> SqlParameter(<span class="stringliteral">&quot;@PropertyType&quot;</span>, property.<a class="code" href="class_shop_model_1_1_product_property.html#afc92bf2ca438dc74ef535b2221e09b1c">TypeOfProperty</a>));
<a name="l00739"></a>00739             sqlCommand.Parameters.Add(<span class="keyword">new</span> SqlParameter(<span class="stringliteral">&quot;@LanguageID&quot;</span>, LanguageID));
<a name="l00740"></a>00740             sqlCommand.Parameters.Add(<span class="keyword">new</span> SqlParameter(<span class="stringliteral">&quot;@IsSearchCriterion&quot;</span>, property.<a class="code" href="class_shop_model_1_1_product_property.html#a7225e2737eec785666b972716ef46026">IsSearchCriterion</a>));
<a name="l00741"></a>00741 
<a name="l00742"></a>00742             <span class="keywordflow">try</span>
<a name="l00743"></a>00743             {
<a name="l00744"></a>00744                 connection.Open();
<a name="l00745"></a>00745 
<a name="l00746"></a>00746                 <span class="keywordtype">id</span> = Convert.ToInt32(sqlCommand.ExecuteScalar());
<a name="l00747"></a>00747 
<a name="l00748"></a>00748                 <span class="keywordflow">if</span> (property.<a class="code" href="class_shop_model_1_1_product_property_detail.html#a280e804f3106f9e2cc526d3cd89334c6" title="Lista możliwych wartości dla danej właściwości.">ValuesList</a> != null &amp;&amp; property.<a class="code" href="class_shop_model_1_1_product_property_detail.html#a280e804f3106f9e2cc526d3cd89334c6" title="Lista możliwych wartości dla danej właściwości.">ValuesList</a>.Count &gt; 0)
<a name="l00749"></a>00749                 {
<a name="l00750"></a>00750                     List&lt;string&gt; newValues = <span class="keyword">new</span> List&lt;string&gt;();
<a name="l00751"></a>00751                     <span class="keywordflow">foreach</span> (<a class="code" href="class_shop_model_1_1_dictionary_value.html" title="Klasa opisująca wartości słownika (Class describing dictionary values).">DictionaryValue</a> current <span class="keywordflow">in</span> property.<a class="code" href="class_shop_model_1_1_product_property_detail.html#a280e804f3106f9e2cc526d3cd89334c6" title="Lista możliwych wartości dla danej właściwości.">ValuesList</a>)
<a name="l00752"></a>00752                     {
<a name="l00753"></a>00753                         newValues.Add(current.<a class="code" href="class_shop_model_1_1_dictionary_value.html#a2da420791553468f28b119002619c052">Name</a>);
<a name="l00754"></a>00754                     }
<a name="l00755"></a>00755 
<a name="l00756"></a>00756                     <a class="code" href="class_shop_d_a_o_1_1_property_d_a_o.html#a1caa360e803cd2af3f8a9f74bd40f242" title="Dodaje wartości do słownika. (Adds values to the dictionary.).">AddDictionaryValue</a>(newValues, <span class="keywordtype">id</span>, LanguageID);
<a name="l00757"></a>00757                 }
<a name="l00758"></a>00758                 <span class="keywordflow">return</span> id;
<a name="l00759"></a>00759             }
<a name="l00760"></a>00760             <span class="keywordflow">catch</span> (Exception ex)
<a name="l00761"></a>00761             {
<a name="l00762"></a>00762                 ErrorLogger.LogError(ex);
<a name="l00763"></a>00763                 <span class="keywordflow">return</span> -1;
<a name="l00764"></a>00764             }
<a name="l00765"></a>00765             <span class="keywordflow">finally</span>
<a name="l00766"></a>00766             {
<a name="l00767"></a>00767                 connection.Close();
<a name="l00768"></a>00768             }
<a name="l00769"></a>00769         }
<a name="l00770"></a>00770 
<a name="l00783"></a><a class="code" href="class_shop_d_a_o_1_1_property_d_a_o.html#af458e9d75de9e500001f39f0c65d096c">00783</a>         <span class="keyword">public</span> <span class="keywordtype">bool</span> <a class="code" href="class_shop_d_a_o_1_1_property_d_a_o.html#af458e9d75de9e500001f39f0c65d096c" title="Usuwa wybraną właściwośc z bazy. (Deletes selected property from the database...">RemoveProperty</a>(<span class="keywordtype">int</span> propertyId)
<a name="l00784"></a>00784         {
<a name="l00785"></a>00785             SqlConnection connection = <span class="keyword">new</span> SqlConnection(connectionString);
<a name="l00786"></a>00786             SqlCommand sqlCommand = connection.CreateCommand();
<a name="l00787"></a>00787 
<a name="l00788"></a>00788             sqlCommand.CommandText = <span class="stringliteral">&quot;RemoveProperty&quot;</span>;
<a name="l00789"></a>00789             sqlCommand.CommandType = CommandType.StoredProcedure;
<a name="l00790"></a>00790 
<a name="l00791"></a>00791             sqlCommand.Parameters.Add(<span class="keyword">new</span> SqlParameter(<span class="stringliteral">&quot;@propertyId&quot;</span>, propertyId));
<a name="l00792"></a>00792 
<a name="l00793"></a>00793             <span class="keywordflow">try</span>
<a name="l00794"></a>00794             {
<a name="l00795"></a>00795                 connection.Open();
<a name="l00796"></a>00796                 sqlCommand.ExecuteNonQuery();
<a name="l00797"></a>00797                 <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00798"></a>00798             }
<a name="l00799"></a>00799             <span class="keywordflow">catch</span> (Exception ex)
<a name="l00800"></a>00800             {
<a name="l00801"></a>00801                 ErrorLogger.LogError(ex);
<a name="l00802"></a>00802                 <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00803"></a>00803             }
<a name="l00804"></a>00804             <span class="keywordflow">finally</span>
<a name="l00805"></a>00805             {
<a name="l00806"></a>00806                 connection.Close();
<a name="l00807"></a>00807             }
<a name="l00808"></a>00808         }
<a name="l00809"></a>00809 
<a name="l00826"></a><a class="code" href="class_shop_d_a_o_1_1_property_d_a_o.html#a0676356bcd143c645b31d69c43cdd991">00826</a>         <span class="keyword">public</span> List&lt;ProductProperty&gt; <a class="code" href="class_shop_d_a_o_1_1_property_d_a_o.html#a0676356bcd143c645b31d69c43cdd991" title="Pobiera właściwości wybranego produktu w wybranym języku. (Downloads properties...">GetProductProperty</a>(<span class="keywordtype">int</span> productId, <span class="keywordtype">int</span>? LanguageID)
<a name="l00827"></a>00827         {
<a name="l00828"></a>00828             <a class="code" href="class_shop_model_1_1_product_property.html" title="Klasa opisująca właściwość produktu. (Class describing a property of the product...">ProductProperty</a> tempProperty;
<a name="l00829"></a>00829             List&lt;ProductProperty&gt; result = <span class="keyword">new</span> List&lt;ProductProperty&gt;();
<a name="l00830"></a>00830             SqlDataReader reader;
<a name="l00831"></a>00831             SqlConnection connection = <span class="keyword">new</span> SqlConnection(connectionString);
<a name="l00832"></a>00832             SqlCommand command = connection.CreateCommand();
<a name="l00833"></a>00833 
<a name="l00834"></a>00834             command.CommandText = <span class="stringliteral">&quot;GetProductProperty&quot;</span>;
<a name="l00835"></a>00835             command.CommandType = CommandType.StoredProcedure;
<a name="l00836"></a>00836             
<a name="l00837"></a>00837             command.Parameters.Add(<span class="keyword">new</span> SqlParameter(<span class="stringliteral">&quot;@product_id&quot;</span>, productId));
<a name="l00838"></a>00838             command.Parameters.Add(<span class="keyword">new</span> SqlParameter(<span class="stringliteral">&quot;@LanguageID&quot;</span>, LanguageID));
<a name="l00839"></a>00839 
<a name="l00840"></a>00840             <span class="keywordflow">try</span>
<a name="l00841"></a>00841             {
<a name="l00842"></a>00842                 connection.Open();
<a name="l00843"></a>00843 
<a name="l00844"></a>00844                 reader = command.ExecuteReader(CommandBehavior.CloseConnection);
<a name="l00845"></a>00845 
<a name="l00846"></a>00846                 <span class="keywordflow">while</span> (reader.Read())
<a name="l00847"></a>00847                 {
<a name="l00848"></a>00848                     tempProperty = <span class="keyword">new</span> <a class="code" href="class_shop_model_1_1_product_property.html" title="Klasa opisująca właściwość produktu. (Class describing a property of the product...">ProductProperty</a>();
<a name="l00849"></a>00849                     tempProperty.<a class="code" href="class_shop_model_1_1_product_property.html#a59e2088b2d228889cbaeee87c3d59eba" title="Id właściwości.">Id</a> = (int)reader[<span class="stringliteral">&quot;IDproperty&quot;</span>];
<a name="l00850"></a>00850                     tempProperty.<a class="code" href="class_shop_model_1_1_product_property.html#afc92bf2ca438dc74ef535b2221e09b1c">TypeOfProperty</a> = (<a class="code" href="namespace_shop_model.html#a98c518c100572eb69c98bd43c7a75a41">PropertyType</a>)reader[<span class="stringliteral">&quot;PropertyType&quot;</span>];
<a name="l00851"></a>00851                     tempProperty.<a class="code" href="class_shop_model_1_1_product_property.html#a6fd3253b96defad3f8adb6928e4f562d">NumericValue</a> = reader[<span class="stringliteral">&quot;NumericValue&quot;</span>] != DBNull.Value ? (decimal?)reader[<span class="stringliteral">&quot;NumericValue&quot;</span>] : null;
<a name="l00852"></a>00852                     tempProperty.<a class="code" href="class_shop_model_1_1_product_property.html#af8d6175437898171abafba0d85724a3a" title="Nazwa właściwości.">Name</a> = reader[<span class="stringliteral">&quot;Name&quot;</span>].ToString();
<a name="l00853"></a>00853                     tempProperty.<a class="code" href="class_shop_model_1_1_product_property.html#af8ae567e758827b982fcb26b8f479678" title="Wartośc właściwości.">Value</a> = reader[<span class="stringliteral">&quot;Value&quot;</span>].ToString();
<a name="l00854"></a>00854                     tempProperty.<a class="code" href="class_shop_model_1_1_product_property.html#a7225e2737eec785666b972716ef46026">IsSearchCriterion</a> = (bool)reader[<span class="stringliteral">&quot;IsSearchCriterion&quot;</span>];
<a name="l00855"></a>00855 
<a name="l00856"></a>00856                     result.Add(tempProperty);
<a name="l00857"></a>00857                 }
<a name="l00858"></a>00858 
<a name="l00859"></a>00859 
<a name="l00860"></a>00860                 reader.Close();
<a name="l00861"></a>00861 
<a name="l00862"></a>00862                 <span class="keywordflow">return</span> result;
<a name="l00863"></a>00863             }
<a name="l00864"></a>00864             <span class="keywordflow">catch</span> (Exception ex)
<a name="l00865"></a>00865             {
<a name="l00866"></a>00866                 ErrorLogger.LogError(ex);
<a name="l00867"></a>00867                 <span class="keywordflow">return</span> <span class="keyword">new</span> List&lt;ProductProperty&gt;();
<a name="l00868"></a>00868             }
<a name="l00869"></a>00869             <span class="keywordflow">finally</span>
<a name="l00870"></a>00870             {
<a name="l00871"></a>00871                 connection.Close();
<a name="l00872"></a>00872             }
<a name="l00873"></a>00873         }
<a name="l00874"></a>00874     }
<a name="l00875"></a>00875 }
</pre></div></div>
<!--- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&nbsp;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&nbsp;</span>Klasy</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&nbsp;</span>Przestrzenie nazw</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&nbsp;</span>Pliki</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&nbsp;</span>Funkcje</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&nbsp;</span>Zmienne</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&nbsp;</span>Wyliczenia</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark">&nbsp;</span>Właściwości</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(8)"><span class="SelectionMark">&nbsp;</span>Zdarzenia</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<hr size="1"/><address style="text-align: right;"><small>Wygenerowano Mon Nov 9 06:08:17 2009 dla eCommerce programem&nbsp;
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.1 </small></address>
</body>
</html>
